const jwt = require('jsonwebtoken');
const {mysecret,expires} = require('../config/config.js')

exports.getToken = (info) => {
    return jwt.sign(info,mysecret,{expiresIn:expires})
}



exports.verifyToken = (token) => {
    return new Promise((resolve,reject) => {
        jwt.verify(token,mysecret,(err,decoded) => {
            if(err){
                resolve({code:0,message:'token验证失败'})
            }

            resolve({code:1,message:'解密成功',info:decoded})
        })
    })
}

